function connectPgSql(_sql) {
  const { Client } = require("pg");
  this.client = new Client({
    user: "postgres",
    host: "localhost",
    database: "hello",
    password: "root",
    port: 5432
  });
  this.startConnet = function(){
    this.client.connect();
  }
  this.getSql =async function(_sql){
    if(_sql){
        console.log(_sql)
        var res = await this.client.query(_sql);
      }else{
        var res = await this.client.query("select id,sum(num) from orders11 group by id");
      }
    return res.rows;
  }
  this.end=function(){
      this.client.end();
  }
}



module.exports = connectPgSql;
